import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
from selenium.webdriver.support.select import Select
testCase="DBshop006_后台订单管理--删除订单流程"

firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,'销售管理','订单管理')

Select(firefox.find_element_by_id('order_state')).select_by_visible_text('已取消')
firefox.find_element_by_xpath('(//button[@type="submit"])[1]').click()
firefox.find_elements_by_name('order_id[]')[0].click()
Select(firefox.find_element_by_id('allEdit')).select_by_visible_text('删除')
firefox.find_element_by_xpath('//button[@onclick="return editAllOrders();"]').click()
firefox.switch_to.alert.accept()
time.sleep(2)

# try:
#     firefox.find_element_by_link_text('打印订单').is_displayed()
#     writeLog("%s 测试通过"%testCase)
#     print("%s 测试通过"%testCase)
# except:
#     writeLog("%s 测试失败" % testCase)
#     getPhoto(firefox)
#     print("%s 测试失败" % testCase)
firefox.quit()